package com.palace.saw.module.app.dal.mysql.articlecategory;

import com.palace.saw.framework.common.pojo.PageResult;
import com.palace.saw.framework.mybatis.core.mapper.BaseMapperX;
import com.palace.saw.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.palace.saw.module.app.controller.admin.articlecategory.vo.ArticleCategoryPageReqVO;
import com.palace.saw.module.app.dal.dataobject.articlecategory.ArticleCategoryDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 文章分类 Mapper
 *
 * @author saw
 */
@Mapper
public interface ArticleCategoryMapper extends BaseMapperX<ArticleCategoryDO> {

    default PageResult<ArticleCategoryDO> selectPage(ArticleCategoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ArticleCategoryDO>()
                .likeIfPresent(ArticleCategoryDO::getName, reqVO.getName())
                .eqIfPresent(ArticleCategoryDO::getPicUrl, reqVO.getPicUrl())
                .eqIfPresent(ArticleCategoryDO::getStatus, reqVO.getStatus())
                .eqIfPresent(ArticleCategoryDO::getSort, reqVO.getSort())
                .betweenIfPresent(ArticleCategoryDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ArticleCategoryDO::getId));
    }

}